<html><head><title>Configuration.h</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="sourcestyles.css" />
</head><body link="blue" vlink="blue">
<h3>File: D:\project4\WaveFrontSensor\Configuration.h</h3>
<SCRIPT>
defaultStatus = "File: D:\\project4\\WaveFrontSensor\\Configuration.h";
top.document.title  = "Configuration.h";
</SCRIPT>
<pre><span class="default"></span><a name="1"><font size=-1>1     </font></a><span class="default"></span><span class="preproc">#pragma </span><span class="default">once</span>
<a name="2"><font size=-1>2     </font></a><span class="default"></span><span class="preproc">#include	</span><span class="string">&lt;qmap.h&gt;</span>
<a name="3"><font size=-1>3     </font></a><span class="string"></span>
<a name="4"><font size=-1>4     </font></a><span class="string"></span>
<a name="5"><font size=-1>5     </font></a><span class="string"></span>
<a name="6"><font size=-1>6     </font></a><span class="string"></span><span class="keyword">class </span><span class="default">Configuration {</span>
<a name="7"><font size=-1>7     </font></a><span class="default"></span><span class="keyword">private</span><span class="default">:</span>
<a name="8"><font size=-1>8     </font></a><span class="default">	QMap&lt;QString, </span><span class="keyword">double</span><span class="default">&gt; conf;</span>
<a name="9"><font size=-1>9     </font></a><span class="default"></span><span class="keyword">public</span><span class="default">:</span>
<a name="10"><font size=-1>10     </font></a><span class="default">	</span><span class="comment">/** 静态配置 */</span>
<a name="11"><font size=-1>11     </font></a><span class="comment">	</span><span class="default">Configuration() {</span>
<a name="12"><font size=-1>12     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;nu_detector&quot;</span><span class="default">, </span><span class="number">512</span><span class="default">);</span>
<a name="13"><font size=-1>13     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;nv_detector&quot;</span><span class="default">, </span><span class="number">512</span><span class="default">);</span>
<a name="14"><font size=-1>14     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;upsampling&quot;</span><span class="default">, </span><span class="number">2</span><span class="default">);</span>
<a name="15"><font size=-1>15     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;grid_period&quot;</span><span class="default">, </span><span class="number">20.e-06</span><span class="default">);</span>
<a name="16"><font size=-1>16     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;dist_mask_to_detector&quot;</span><span class="default">, </span><span class="number">0.2</span><span class="default">);</span>
<a name="17"><font size=-1>17     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;lowest_fringe_order&quot;</span><span class="default">, </span><span class="number">8</span><span class="default">);</span>
<a name="18"><font size=-1>18     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;centroid_power&quot;</span><span class="default">, </span><span class="number">1.7</span><span class="default">);</span>
<a name="19"><font size=-1>19     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;detector_pixel_size&quot;</span><span class="default">, </span><span class="number">1.48e-06</span><span class="default">);</span>
<a name="20"><font size=-1>20     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;wavelength&quot;</span><span class="default">, </span><span class="number">1.0972e-10</span><span class="default">);</span>
<a name="21"><font size=-1>21     </font></a><span class="default">	}</span>
<a name="22"><font size=-1>22     </font></a><span class="default"></span>
<a name="23"><font size=-1>23     </font></a><span class="default">	</span><span class="comment">/** 保留一个动态配置接口 */</span>
<a name="24"><font size=-1>24     </font></a><span class="comment">	/**</span>
<a name="25"><font size=-1>25     </font></a><span class="comment">	 * nu_detector nu检测器</span>
<a name="26"><font size=-1>26     </font></a><span class="comment">	 * nv_detector nv检测器</span>
<a name="27"><font size=-1>27     </font></a><span class="comment">	 * unsmapling 上采样</span>
<a name="28"><font size=-1>28     </font></a><span class="comment">	 * grid period 网格周期</span>
<a name="29"><font size=-1>29     </font></a><span class="comment">	 * dist_mask_to_detector 区域掩码检测器</span>
<a name="30"><font size=-1>30     </font></a><span class="comment">	 * lowest_fringe_order 最低边缘？？</span>
<a name="31"><font size=-1>31     </font></a><span class="comment">	 * centroid_power 质心</span>
<a name="32"><font size=-1>32     </font></a><span class="comment">	 * detector_pixel_sie 检测像素点的区域大小</span>
<a name="33"><font size=-1>33     </font></a><span class="comment">	 * wave length 波长</span>
<a name="34"><font size=-1>34     </font></a><span class="comment">	 */</span>
<a name="35"><font size=-1>35     </font></a><span class="comment">	</span><span class="default">Configuration(</span><span class="keyword">int</span><span class="default">&amp; nu_detector_size, </span><span class="keyword">int</span><span class="default">&amp; nv_detector_size,</span>
<a name="36"><font size=-1>36     </font></a><span class="default">		</span><span class="keyword">double</span><span class="default">&amp; upsampling, </span><span class="keyword">double</span><span class="default">&amp; grid_period,</span>
<a name="37"><font size=-1>37     </font></a><span class="default">		</span><span class="keyword">double</span><span class="default">&amp; dist_mask_to_detector, </span><span class="keyword">int</span><span class="default">&amp; lowest_fringe_order,</span>
<a name="38"><font size=-1>38     </font></a><span class="default">		</span><span class="keyword">double</span><span class="default">&amp; centroid_power, </span><span class="keyword">double</span><span class="default">&amp; detector_pixel_size,</span>
<a name="39"><font size=-1>39     </font></a><span class="default">		</span><span class="keyword">double</span><span class="default">&amp; wavelength) {</span>
<a name="40"><font size=-1>40     </font></a><span class="default"></span>
<a name="41"><font size=-1>41     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;nu_detector&quot;</span><span class="default">, </span><span class="keyword">static_cast</span><span class="default">&lt;</span><span class="keyword">double</span><span class="default">&gt;(nu_detector_size));</span>
<a name="42"><font size=-1>42     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;nv_detector&quot;</span><span class="default">, </span><span class="keyword">static_cast</span><span class="default">&lt;</span><span class="keyword">double</span><span class="default">&gt;(nv_detector_size));</span>
<a name="43"><font size=-1>43     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;upsampling&quot;</span><span class="default">, upsampling);</span>
<a name="44"><font size=-1>44     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;grid_period&quot;</span><span class="default">, grid_period);</span>
<a name="45"><font size=-1>45     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;dist_mask_to_detector&quot;</span><span class="default">, dist_mask_to_detector);</span>
<a name="46"><font size=-1>46     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;lowest_fringe_order&quot;</span><span class="default">, </span><span class="keyword">static_cast</span><span class="default">&lt;</span><span class="keyword">double</span><span class="default">&gt;(lowest_fringe_order));</span>
<a name="47"><font size=-1>47     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;centroid_power&quot;</span><span class="default">, centroid_power);</span>
<a name="48"><font size=-1>48     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;detector_pixel_size&quot;</span><span class="default">, detector_pixel_size);</span>
<a name="49"><font size=-1>49     </font></a><span class="default">		conf.insert(</span><span class="string">&quot;wavelength&quot;</span><span class="default">, wavelength);</span>
<a name="50"><font size=-1>50     </font></a><span class="default">	}</span>
<a name="51"><font size=-1>51     </font></a><span class="default"></span>
<a name="52"><font size=-1>52     </font></a><span class="default">	</span><span class="keyword">inline auto operator</span><span class="default">[](</span><span class="keyword">const </span><span class="default">QString&amp; key) -&gt; decltype(conf[key]) {</span>
<a name="53"><font size=-1>53     </font></a><span class="default">		</span><span class="keyword">if </span><span class="default">(conf.find(key) == conf.end()) {</span>
<a name="54"><font size=-1>54     </font></a><span class="default"></span>
<a name="55"><font size=-1>55     </font></a><span class="default">			conf.insert(key, </span><span class="number">0.</span><span class="default">);</span>
<a name="56"><font size=-1>56     </font></a><span class="default"></span>
<a name="57"><font size=-1>57     </font></a><span class="default">		}</span>
<a name="58"><font size=-1>58     </font></a><span class="default">		</span><span class="keyword">return </span><span class="default">conf[key];</span>
<a name="59"><font size=-1>59     </font></a><span class="default">	}</span>
<a name="60"><font size=-1>60     </font></a><span class="default"></span>
<a name="61"><font size=-1>61     </font></a><span class="default">	</span><span class="keyword">inline bool  </span><span class="default">insert(</span><span class="keyword">const </span><span class="default">QString&amp; key, </span><span class="keyword">double </span><span class="default">value) {</span>
<a name="62"><font size=-1>62     </font></a><span class="default"></span>
<a name="63"><font size=-1>63     </font></a><span class="default">		</span><span class="keyword">if </span><span class="default">(conf.find(key) == conf.end()) {</span>
<a name="64"><font size=-1>64     </font></a><span class="default"></span>
<a name="65"><font size=-1>65     </font></a><span class="default">			</span><span class="keyword">return false</span><span class="default">;</span>
<a name="66"><font size=-1>66     </font></a><span class="default">		}</span>
<a name="67"><font size=-1>67     </font></a><span class="default">		conf.insert(key, value);</span>
<a name="68"><font size=-1>68     </font></a><span class="default"></span>
<a name="69"><font size=-1>69     </font></a><span class="default">		</span><span class="keyword">return true</span><span class="default">;</span>
<a name="70"><font size=-1>70     </font></a><span class="default">	}</span>
<a name="71"><font size=-1>71     </font></a><span class="default"></span>
<a name="72"><font size=-1>72     </font></a><span class="default">	~Configuration() {</span>
<a name="73"><font size=-1>73     </font></a><span class="default"></span>
<a name="74"><font size=-1>74     </font></a><span class="default">	}</span>
<a name="75"><font size=-1>75     </font></a><span class="default">};</span>
<a name="76"><font size=-1>76     </font></a><span class="default"></span>
</pre></body></html>
